package com.zhike.service.serviceimpl;



import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.google.gson.Gson;
import com.zhike.mapper.LaboratoryMapper;
import com.zhike.mapper.UserMapper;
import com.zhike.model.ContractRview;
import com.zhike.model.LabsFlowA;
import com.zhike.model.LbtNumberType;
import com.zhike.model.Rootobject;
import com.zhike.model.Sample;
import com.zhike.model.SceneFlow;
import com.zhike.model.Step;
import com.zhike.model.Users;
import com.zhike.model.WorkFlowTask;
import com.zhike.service.LaboratoryService;
import com.zhike.util.BasicsUtil;
import com.zhike.util.DataSourceEnum;
import com.zhike.util.DataSourceHolder;
import com.zhike.util.DateUtil;
import com.zhike.util.Jdpush;
import com.zhike.util.JsonUtil;
import com.zhike.util.RandomGUID;

@Service
public class LaboratoryServiceImpl implements LaboratoryService {

	@Resource
	LaboratoryMapper laboratoryMapper;

	@Resource
	UserMapper userMapper;
	public String ContractRviewDetail(ContractRview contractRview) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		JsonUtil jsonUtil = new JsonUtil();
		//查询详细
		ContractRview cR  = laboratoryMapper.ContractRviewDetail(contractRview);
		if (cR==null) {
			return jsonUtil.blank(false, 400, "此消息已删除");
		}
		if (null !=cR.getXmfzr() && !"".equals(cR.getXmfzr())) {
			String id= cR.getXmfzr().substring(2);
			//根据项目负责人id查询姓名
			String  str = laboratoryMapper.getUserName(id.toUpperCase());
			cR.setXmfzrxm(str);
		}
			
		WorkFlowTask workFlowTask = new WorkFlowTask();
		workFlowTask.setID(contractRview.getLimsId());
		WorkFlowTask messageDetail = laboratoryMapper.getMessageDetail(workFlowTask);
		

		cR.setPrevStepID(messageDetail.getPrevStepID());
		cR.setStepID(messageDetail.getStepID());
		cR.setStepName(messageDetail.getStepName());
		jsonUtil.add(cR);
		return jsonUtil.getJson();
	}

	public String numberGet(LbtNumberType lbtNumberType) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		
		//通过类型id拿到编号格式
		LbtNumberType lType = laboratoryMapper.numberGet(lbtNumberType.getTypeID());
		//通过编号格式设置具体编号
		String rules = lType.getRules();
		String numberRules = BasicsUtil.numberRules(rules);
		lbtNumberType.setNumber(numberRules);
		//拿到类型id 和 创建者id 设置创建时间和编号
		String currentTime = DateUtil.getCurrentTime();
		lbtNumberType.setCreaterTime(currentTime);
		lbtNumberType.setTypeID(lType.getID());

		//编号存进数据库
		laboratoryMapper.numberInsert(lbtNumberType);
		JsonUtil jsonUtil = new JsonUtil();
		jsonUtil.add(lbtNumberType);
		return jsonUtil.getJson();
	}

	@Override
	public String detectionStructure(LbtNumberType lbtNumberType) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		
		List<LbtNumberType> arrayList = new ArrayList<LbtNumberType>();
		arrayList = laboratoryMapper.detectionStructure(lbtNumberType);
		JsonUtil jsonUtil = new JsonUtil();
		jsonUtil.setList(arrayList);
		return jsonUtil.getJson();
	}

	public String reviewSubmit(ContractRview contractRview) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		WorkFlowTask workFlowTask = new WorkFlowTask();
		workFlowTask.setID(contractRview.getPrevID());
		//当前消息的具体信息
		WorkFlowTask messageDetail = laboratoryMapper.getMessageDetail(workFlowTask);
	
		
		//如果完成
		if (contractRview.getIsFinish()==1) {
			//修改已经完成的待办事项的状态	
			contractRview.setOpenTime(DateUtil.getCurrentTime());
			contractRview.setCompletedTime1(DateUtil.getCurrentTime());
			laboratoryMapper.backlogStatus(contractRview);
			
			laboratoryMapper.reviewSubmit(contractRview);
			
			//部门评审事项插入代办列表数据库
			contractRview.setStepID("4ce17fcc-eb59-4996-b02c-e22edea5b6b2");
			contractRview.setStepName("领导");
			contractRview.setReceiveTime(DateUtil.getCurrentTime());
			contractRview.setSendTimeTicks(DateUtil.getCurrentTime());
			String string = new RandomGUID().toString();
			contractRview.setGUID(string);
			laboratoryMapper.backlogInsert(contractRview);
			

			//获取两个别名 分别推送
			DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
			Users users=new Users();
			users.setId(contractRview.getReceiveID());
			Users detailUser = userMapper.getDetailUser(users);
			String id = detailUser.getId();
			String account_ID = detailUser.getAccount_ID();
			
			
			Map<String, String> parm1 = new HashMap<>();
			Map<String, String> parm = new HashMap<>();
			String dateTime = contractRview.getReceiveTime();
			String newDate = dateTime.substring(0, 19);
			parm.put("title", contractRview.getTitle());
			parm.put("msg", contractRview.getTitle()+"      "+newDate);
			parm.put("messageType", "待办事项");
			parm.put("type", "0");
			parm.put("alias",id.replaceAll("-", ""));
			
			parm1.put("title", contractRview.getTitle());
			parm1.put("msg", contractRview.getTitle()+"      "+newDate);
			parm1.put("messageType", "待办事项");
			parm1.put("type", "0");
			parm1.put("alias",account_ID.replaceAll("-", ""));
			Jdpush.jpushAlias(parm);
			Jdpush.jpushAlias(parm1);
				
		}
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		if (contractRview.getIsFinish()==0) {
			
			laboratoryMapper.reviewSubmit(contractRview);
			//改变消息为已读 状态为退回
			workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
			workFlowTask.setOpenTime(DateUtil.getCurrentTime());
			workFlowTask.setStatus(2);
			workFlowTask.setLimsId(messageDetail.getID());
			laboratoryMapper.updateMessageState(workFlowTask);
			//生成一条新的消息 退回给发送人
			//获取步骤id  步骤名称
			WorkFlowTask newWork = new WorkFlowTask();
			newWork.setStepID("09af1464-bed6-41d1-90d5-d215abeeb110");
			newWork.setStepName("合同");
			
			newWork.setPrevStepID(messageDetail.getStepID());
			newWork.setPrevID(messageDetail.getID());
			newWork.setID(new RandomGUID().toString());
			//接收人id
			newWork.setReceiveID(messageDetail.getSenderID());
			newWork.setSenderID(messageDetail.getReceiveID());
			newWork.setReceiveName(messageDetail.getSenderName());
			newWork.setSenderName(messageDetail.getReceiveName());
			Integer sort = messageDetail.getSort();
			newWork.setFlowID(messageDetail.getFlowID());
			newWork.setInstanceID(messageDetail.getInstanceID());
			newWork.setReceiveTime(DateUtil.getCurrentTime());
			newWork.setSort(sort+1);
			newWork.setStatus(0);
			newWork.setSenderTime(DateUtil.getCurrentTime());
			newWork.setType(0);
			newWork.setNote("消息退回");
			newWork.setGroupID(messageDetail.getGroupID());
			newWork.setTitle(messageDetail.getTitle());
			//插入 代办事项列表
			laboratoryMapper.insertWorkOrder(newWork);
			//发起推送
			DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
			Users users=new Users();
			users.setId(newWork.getReceiveID());
			Users detailUser = userMapper.getDetailUser(users);
			
			
			Map<String, String> parm = new HashMap<>();
			parm.put("title",messageDetail.getTitle());
			parm.put("messageType", "待办事项");
			parm.put("type", "0");
			parm.put("msg", "退回合同"+"         "+DateUtil.getCurrentTime());
			parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
			Jdpush.jpushAlias(parm);
			
			Map<String, String> parm1 = new HashMap<>();
			parm1.put("title",messageDetail.getTitle());
			parm.put("messageType", "待办事项");
			parm.put("type", "0");
			parm1.put("msg", "退回合同"+"         "+DateUtil.getCurrentTime());
			parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
			Jdpush.jpushAlias(parm1);	
		}
		
		return JsonUtil.blank(true, 200, "调用接口成功");
	}

	
	@Override
	public String contractUpdate(WorkFlowTask workFlowTask, ContractRview contractRview) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		WorkFlowTask workFlowTasks = new WorkFlowTask();
		workFlowTasks.setID(contractRview.getLimsId());
		//当前消息的具体信息
		System.out.println(contractRview.getLimsId());
		WorkFlowTask messageDetail = laboratoryMapper.getMessageDetail(workFlowTasks);
		
		laboratoryMapper.reviewSubmit(contractRview);
		//改变消息为已读 状态为退回
		workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
		workFlowTask.setOpenTime(DateUtil.getCurrentTime());
		workFlowTask.setStatus(2);
		workFlowTask.setLimsId(contractRview.getLimsId());
		laboratoryMapper.updateMessageState(workFlowTask);
		
		//生成一条新的消息 退回给发送人
		//获取步骤id  步骤名称
		WorkFlowTask newWork = new WorkFlowTask();
		newWork.setStepID("2fbfd158-622c-4326-a505-1638e5434461");
		newWork.setStepName("部门");
		
		newWork.setPrevStepID(messageDetail.getStepID());
		newWork.setPrevID(messageDetail.getID());
		newWork.setID(new RandomGUID().toString());
		//接收人id
		newWork.setReceiveID(workFlowTask.getReceiveID());
		newWork.setSenderID(workFlowTask.getSenderID());
		newWork.setReceiveName(workFlowTask.getReceiveName());
		newWork.setSenderName(workFlowTask.getSenderName());
		Integer sort = messageDetail.getSort();
		newWork.setFlowID(messageDetail.getFlowID());
		newWork.setInstanceID(messageDetail.getInstanceID());
		newWork.setReceiveTime(DateUtil.getCurrentTime());
		newWork.setSort(sort+1);
		newWork.setStatus(0);
		newWork.setSenderTime(DateUtil.getCurrentTime());
		newWork.setType(0);
		newWork.setNote("");
		newWork.setGroupID(messageDetail.getGroupID());
		newWork.setTitle(messageDetail.getTitle());
		//插入 代办事项列表
		laboratoryMapper.insertWorkOrder(newWork);
		//发起推送
		DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
		Users users=new Users();
		users.setId(workFlowTask.getReceiveID());
		Users detailUser = userMapper.getDetailUser(users);
		
		
		Map<String, String> parm = new HashMap<>();
		parm.put("title",messageDetail.getTitle());
		parm.put("messageType", "待办事项");
		parm.put("type", "0");
		parm.put("msg", "发送到部门"+"         "+DateUtil.getCurrentTime());
		parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
		Jdpush.jpushAlias(parm);
		
		Map<String, String> parm1 = new HashMap<>();
		parm1.put("title",messageDetail.getTitle());
		parm.put("messageType", "待办事项");
		parm.put("type", "0");
		parm1.put("msg", "发送到部门"+"         "+DateUtil.getCurrentTime());
		parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
		Jdpush.jpushAlias(parm1);	
		return JsonUtil.blank(true, 200, "调用接口成功");
	}
	@Override
	public String leadTheReview(ContractRview contractRview) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		WorkFlowTask workFlowTask = new WorkFlowTask();
		workFlowTask.setID(contractRview.getPrevID());
		//当前消息的具体信息
		WorkFlowTask messageDetail = laboratoryMapper.getMessageDetail(workFlowTask);
		if (contractRview.getIsFinish()==1) {
			laboratoryMapper.leadTheReview(contractRview);
			//推送给项目负责人
			String string = laboratoryMapper.sendIDSearch(contractRview);
			
			
			DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
			Users users=new Users();
			users.setId(string);
			Users detailUser = userMapper.getDetailUser(users);
			
			String timeStamp3Date = DateUtil.getCurrentTime();
			
				Map<String, String> parm = new HashMap<>();
				String id = detailUser.getId();
				parm.put("title",contractRview.getTitle());
				parm.put("messageType", "待办事项");
				parm.put("msg", "评审已完成"+"         "+timeStamp3Date);
				parm.put("alias",id.toUpperCase().replaceAll("-", ""));
				Jdpush.jpushAlias(parm);
			
			String account_ID = detailUser.getAccount_ID();
			Map<String, String> parm1 = new HashMap<>();
			parm1.put("title",contractRview.getTitle());
			parm1.put("messageType", "待办事项");
			parm1.put("msg", "评审已完成"+"         "+timeStamp3Date);
			parm1.put("alias",account_ID.toUpperCase().replaceAll("-", ""));
			Jdpush.jpushAlias(parm1);
			
			//修改待办事项状态
			DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
			contractRview.setCompletedTime1(timeStamp3Date);
			laboratoryMapper.backlogStatus(contractRview);
		}
		if (contractRview.getIsFinish()==0) {
			laboratoryMapper.leadTheReview(contractRview);
			//改变消息为已读 状态为退回
			workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
			workFlowTask.setOpenTime(DateUtil.getCurrentTime());
			workFlowTask.setStatus(3);
			workFlowTask.setLimsId(messageDetail.getID());
			laboratoryMapper.updateMessageState(workFlowTask);
			//生成一条新的消息 退回给发送人
			//获取步骤id  步骤名称
			WorkFlowTask newWork = new WorkFlowTask();
			newWork.setStepID("e7926581-f62f-4a80-a080-b9cf1d27787d");
			newWork.setStepName("部门修改");
			
			newWork.setPrevStepID(messageDetail.getStepID());
			newWork.setPrevID(messageDetail.getID());
			newWork.setID(new RandomGUID().toString());
			//接收人id
			newWork.setReceiveID(messageDetail.getSenderID());
			newWork.setSenderID(messageDetail.getReceiveID());
			newWork.setReceiveName(messageDetail.getSenderName());
			newWork.setSenderName(messageDetail.getReceiveName());
			Integer sort = messageDetail.getSort();
			newWork.setFlowID(messageDetail.getFlowID());
			newWork.setInstanceID(messageDetail.getInstanceID());
			newWork.setReceiveTime(DateUtil.getCurrentTime());
			newWork.setSort(sort+1);
			newWork.setStatus(0);
			newWork.setSenderTime(DateUtil.getCurrentTime());
			newWork.setType(0);
			newWork.setNote("消息退回");
			newWork.setGroupID(messageDetail.getGroupID());
			newWork.setTitle(messageDetail.getTitle());
			//插入 代办事项列表
			laboratoryMapper.insertWorkOrder(newWork);
			//发起推送
			DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
			Users users=new Users();
			users.setId(newWork.getReceiveID());
			Users detailUser = userMapper.getDetailUser(users);
			
			
			Map<String, String> parm = new HashMap<>();
			parm.put("title",messageDetail.getTitle());
			parm.put("messageType", "待办事项");
			parm.put("type", "0");
			parm.put("msg", "退回部门修改"+"         "+DateUtil.getCurrentTime());
			parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
			Jdpush.jpushAlias(parm);
			
			Map<String, String> parm1 = new HashMap<>();
			parm1.put("title",messageDetail.getTitle());
			parm.put("messageType", "待办事项");
			parm.put("type", "0");
			parm1.put("msg", "退回部门修改"+"         "+DateUtil.getCurrentTime());
			parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
			Jdpush.jpushAlias(parm1);	
			
		}
		
		return JsonUtil.blank(true, 200, "调用接口成功");
	}

	@Override
	public String SceneFlowDetail(SceneFlow sceneFlow) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		SceneFlow scene = laboratoryMapper.SceneFlowDetail(sceneFlow);
		if (scene.getFSR()!=null) {
			String fsrName = laboratoryMapper.getNameById(scene.getFSR().substring(2));
			scene.setFSRMZ(fsrName);
		}if (scene.getJSR()!=null) {
			String jsrName = laboratoryMapper.getNameById(scene.getJSR().substring(2));
			scene.setJSRMZ(jsrName);
		}
		
		JsonUtil jsonUtil = new JsonUtil();
		jsonUtil.add(scene);
		return jsonUtil.getJson();
	}

	@Override
	public String passWordContrast(Users users) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
		//输入的密码加密
		String md5 = BasicsUtil.getMD5(users.getId().toLowerCase()+users.getPassWord());
		String md52 = BasicsUtil.getMD5(md5);
		//查询数据库密码
		Users detailUser = userMapper.getDetailUser(users);
		
		//进行比对
		if (!detailUser.getAccount_Password().equals(md52)) {
			return JsonUtil.blank(false, 400, "密码不正确");
		}else return JsonUtil.blank(true, 200, "密码正确");
		
	}

	@Override
	public String workOrder(WorkFlowTask workFlowTask) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		//通过id查询消息详情
		WorkFlowTask newWork = laboratoryMapper.getMessageDetail(workFlowTask);
		String prevID = newWork.getPrevID();
		newWork.setID(prevID);
		WorkFlowTask newWork1 = laboratoryMapper.getMessageDetail(newWork);
		//获取接受时间
		String completedTime1 = newWork1.getCompletedTime1();
	
		//首先处理待办事项改为已读 并且更改字段
		workFlowTask.setOpenTime(DateUtil.getCurrentTime());
		workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
		workFlowTask.setReceiveTime(completedTime1);
		laboratoryMapper.workOrder(workFlowTask);
		laboratoryMapper.workOrderComment(workFlowTask);

		DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
		Users users=new Users();
		users.setId(workFlowTask.getReceiveID());
		Users detailUser = userMapper.getDetailUser(users);
		
		
		Map<String, String> parm = new HashMap<>();
		parm.put("title",newWork.getTitle());
		parm.put("messageType", "待办事项");
		parm.put("msg", "派工已完成"+"         "+DateUtil.getCurrentTime());
		parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
		Jdpush.jpushAlias(parm);
		
		Map<String, String> parm1 = new HashMap<>();
		parm1.put("title",newWork.getTitle());
		parm1.put("messageType", "待办事项");
		parm1.put("msg", "派工已完成"+"         "+DateUtil.getCurrentTime());
		parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", ""));
		Jdpush.jpushAlias(parm1);
		//
		return JsonUtil.blank(true, 200, "调用接口成功");
	}

	@Override
	public String auditCommit(WorkFlowTask workFlowTask, SceneFlow sceneFlow) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		Map<String, String> parm = new HashMap<>();
		Map<String, String> parm1 = new HashMap<>();
		//先修改审核提交的结果
		laboratoryMapper.updateAuditCommit(sceneFlow);
		
		workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
		workFlowTask.setStatus(2);
		workFlowTask.setOpenTime(DateUtil.getCurrentTime());
		//修改消息状态为已读
		WorkFlowTask flowTask = new WorkFlowTask();                       
		flowTask.setID(workFlowTask.getLimsId());
		laboratoryMapper.updateMessageState(workFlowTask);
		
		//发送给下一个流程信息
		//通过id查询消息详情
				WorkFlowTask newWork = laboratoryMapper.getMessageDetail(flowTask);
				
				//通过流程id获得json字符串 解析获得具体的流程
				String flowID = newWork.getFlowID();
				String returnJson = laboratoryMapper.getreturnJson(flowID);
				
				//解析json字符串
				Gson gson = new Gson();
				Rootobject gda = gson.fromJson(returnJson, Rootobject.class);
				Step[] steps = gda.getSteps();
				Integer jInteger=0;
				for (int i = 0; i < steps.length; i++) {
					String id2 = steps[i].getId();
					//获取流程的list 如果和当前流程id相同 则 获取下一个流程的id
					if (id2.equals(newWork.getStepID().toLowerCase())) {
						if (sceneFlow.getLbt2().equals("通过")) {
							parm.put("msg", "审批"+"         "+DateUtil.getCurrentTime());
							parm1.put("msg", "审批"+"         "+DateUtil.getCurrentTime());
							jInteger=i+1;
							newWork.setNote("");
						}
						if (sceneFlow.getLbt2().equals("不通过")) {
							parm.put("msg", "试验修改"+"         "+DateUtil.getCurrentTime());
							parm1.put("msg", "试验修改"+"         "+DateUtil.getCurrentTime());
							jInteger=i+3;
							newWork.setNote("退回任务");
						}
						break;
					}
				}
				
				newWork.setPrevStepID(newWork.getStepID());
				newWork.setStepID(steps[jInteger].getId());
				newWork.setStepName(steps[jInteger].getName());
				newWork.setPrevID(newWork.getID());
				newWork.setID(new RandomGUID().toString());
				newWork.setReceiveID(workFlowTask.getReceiveID());
				newWork.setSenderID(workFlowTask.getSenderID());
				
				String receiveName = laboratoryMapper.getNameById(workFlowTask.getReceiveID());
				String senderName = laboratoryMapper.getNameById(workFlowTask.getSenderID());
				
				newWork.setReceiveName(receiveName);
				newWork.setSenderName(senderName);
				Integer sort = newWork.getSort();
				newWork.setReceiveTime(DateUtil.getCurrentTime());
				newWork.setSort(sort+1);
				newWork.setStatus(0);
				newWork.setSenderTime(DateUtil.getCurrentTime());
				//派工的具体事项 代办事项列表
				laboratoryMapper.insertWorkOrder(newWork);
				
				//发送推送
				DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
				Users users=new Users();
				users.setId(workFlowTask.getReceiveID());
				Users detailUser = userMapper.getDetailUser(users);
				
				

				parm.put("title",newWork.getTitle());
				parm.put("messageType", "待办事项");

				parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
				Jdpush.jpushAlias(parm);
				
				parm1.put("title",newWork.getTitle());
				parm1.put("messageType", "待办事项");
				parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", ""));
				Jdpush.jpushAlias(parm1);
		
		return JsonUtil.blank(true, 200, "提交审核成功");
	}

	@Override
	public String approveCommit(WorkFlowTask workFlowTask, SceneFlow sceneFlow) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		Map<String, String> parm = new HashMap<>();
		Map<String, String> parm1 = new HashMap<>();
		
		//先修改审核提交的结果
		laboratoryMapper.updateapproveCommit(sceneFlow);
		
		workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
		workFlowTask.setStatus(2);
		workFlowTask.setOpenTime(DateUtil.getCurrentTime());
		//修改消息状态为已读
		WorkFlowTask flowTask = new WorkFlowTask();                       
		flowTask.setID(workFlowTask.getLimsId());
		laboratoryMapper.updateMessageState(workFlowTask);
		
		//发送给下一个流程信息
		
		//通过id查询消息详情
		WorkFlowTask newWork = laboratoryMapper.getMessageDetail(flowTask);
		
		//通过流程id获得json字符串 解析获得具体的流程
		String flowID = newWork.getFlowID();
		String returnJson = laboratoryMapper.getreturnJson(flowID);
		
		//解析json字符串
		Gson gson = new Gson();
		Rootobject gda = gson.fromJson(returnJson, Rootobject.class);
		Step[] steps = gda.getSteps();
		Integer jInteger=0;
		for (int i = 0; i < steps.length; i++) {
			String id2 = steps[i].getId();
			//获取流程的list 如果和当前流程id相同 则 获取下一个流程的id
			if (id2.equals(newWork.getStepID().toLowerCase())) {
				if (sceneFlow.getLbt3().equals("通过")) {
					parm.put("msg", "报告"+"         "+DateUtil.getCurrentTime());
					parm1.put("msg", "报告"+"         "+DateUtil.getCurrentTime());
					jInteger=i+1;
					newWork.setNote("");
				}
				if (sceneFlow.getLbt3().equals("不通过退回至审核")) {
					parm.put("msg", "审核"+"         "+DateUtil.getCurrentTime());
					parm1.put("msg", "审核"+"         "+DateUtil.getCurrentTime());
					jInteger=i-1;
					newWork.setNote("退回任务");
				}
				if (sceneFlow.getLbt3().equals("不通过退回至试验")) {
					parm.put("msg", "试验修改"+"         "+DateUtil.getCurrentTime());
					parm1.put("msg", "试验修改"+"         "+DateUtil.getCurrentTime());
					jInteger=i+2;
					newWork.setNote("退回任务");
				}
				break;
			}
		}
		
		newWork.setPrevStepID(newWork.getStepID());
		newWork.setStepID(steps[jInteger].getId());
		newWork.setStepName(steps[jInteger].getName());
		newWork.setPrevID(newWork.getID());
		newWork.setID(new RandomGUID().toString());
		newWork.setReceiveID(workFlowTask.getReceiveID());
		newWork.setSenderID(workFlowTask.getSenderID());
		
		String receiveName = laboratoryMapper.getNameById(workFlowTask.getReceiveID());
		String senderName = laboratoryMapper.getNameById(workFlowTask.getSenderID());
		
		newWork.setReceiveName(receiveName);
		newWork.setSenderName(senderName);
		Integer sort = newWork.getSort();
		newWork.setReceiveTime(DateUtil.getCurrentTime());
		newWork.setSort(sort+1);
		newWork.setStatus(0);
		newWork.setSenderTime(DateUtil.getCurrentTime());
		//派工的具体事项 代办事项列表
		laboratoryMapper.insertWorkOrder(newWork);
		
		//发送推送
		DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
		Users users=new Users();
		users.setId(workFlowTask.getReceiveID());
		Users detailUser = userMapper.getDetailUser(users);
		
		

		parm.put("title",newWork.getTitle());
		parm.put("messageType", "待办事项");

		parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
		Jdpush.jpushAlias(parm);
		

		parm1.put("title",newWork.getTitle());
		parm1.put("messageType", "待办事项");

		parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", ""));
		Jdpush.jpushAlias(parm1);

		return JsonUtil.blank(true, 200, "提交审批成功");
	}

	@Override
	public String approveOver(WorkFlowTask workFlowTask) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		
		workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
		workFlowTask.setStatus(2);
		workFlowTask.setOpenTime(DateUtil.getCurrentTime());
		//修改消息状态为已读
		laboratoryMapper.updateMessageState(workFlowTask);
		workFlowTask.setID(workFlowTask.getLimsId());
		WorkFlowTask messageDetail = laboratoryMapper.getMessageDetail(workFlowTask);
		System.out.println(messageDetail.getInstanceID());
		//根据 instenceID查询发送人id
		WorkFlowTask workFlowTask2 = laboratoryMapper.getSenderID(messageDetail);
		System.out.println(workFlowTask2);
		//发送推送
		DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
		Users users=new Users();
		users.setId(workFlowTask2.getSenderID());
		Users detailUser = userMapper.getDetailUser(users);
		
		Map<String, String> parm = new HashMap<>();
		parm.put("title",workFlowTask2.getTitle());
		parm.put("messageType", "待办事项");
		parm.put("msg", "出报告完成"+"         "+DateUtil.getCurrentTime());
		parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
		Jdpush.jpushAlias(parm);
		
		Map<String, String> parm1 = new HashMap<>();
		parm1.put("title",workFlowTask2.getTitle());
		parm1.put("messageType", "待办事项");
		parm1.put("msg", "出报告完成"+"         "+DateUtil.getCurrentTime());
		parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", ""));
		Jdpush.jpushAlias(parm1);

		
		
		return JsonUtil.blank(true, 200, "调用接口成功");
	}

	@Override
	public String projectList(SceneFlow sceneFlow) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
	 List<SceneFlow> list = new ArrayList<SceneFlow>();
	 list = laboratoryMapper.projectList(sceneFlow);
	 JsonUtil jsonUtil = new JsonUtil();
	 jsonUtil.setList(list);
		return jsonUtil.getJson();
	}

	@Override
	public String workorderSearch(SceneFlow sceneFlow) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		SceneFlow sF=laboratoryMapper.workorderSearch(sceneFlow);
		JsonUtil jsonUtil = new JsonUtil();
		jsonUtil.add(sF);
		return jsonUtil.getJson();
	}

	@Override
	public String testAudit(SceneFlow sceneFlow, WorkFlowTask workFlowTask) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		//先修改审核提交的结果
		laboratoryMapper.testAudit(sceneFlow);
		
		workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
		workFlowTask.setStatus(2);
		workFlowTask.setOpenTime(DateUtil.getCurrentTime());
		//修改消息状态为已读
		WorkFlowTask flowTask = new WorkFlowTask();                       
		flowTask.setID(workFlowTask.getLimsId());
		laboratoryMapper.updateMessageState(workFlowTask);
		
		//发送给下一个流程信息
		//通过id查询消息详情
				WorkFlowTask newWork = laboratoryMapper.getMessageDetail(flowTask);
				
				//通过流程id获得json字符串 解析获得具体的流程
				String flowID = newWork.getFlowID();
				String returnJson = laboratoryMapper.getreturnJson(flowID);
				
				//解析json字符串
				Gson gson = new Gson();
				Rootobject gda = gson.fromJson(returnJson, Rootobject.class);
				Step[] steps = gda.getSteps();
				Integer jInteger=0;
				for (int i = 0; i < steps.length; i++) {
					String id2 = steps[i].getId();
					//获取流程的list 如果和当前流程id相同 则 获取下一个流程的id
					if (id2.equals(newWork.getStepID().toLowerCase())) {
							jInteger=i-3;
						
						break;
					}
				}
				
				newWork.setPrevStepID(newWork.getStepID());
				newWork.setStepID(steps[jInteger].getId());
				newWork.setStepName(steps[jInteger].getName());
				newWork.setPrevID(newWork.getID());
				newWork.setID(new RandomGUID().toString());
				newWork.setReceiveID(workFlowTask.getReceiveID());
				newWork.setSenderID(workFlowTask.getSenderID());
				
				String receiveName = laboratoryMapper.getNameById(workFlowTask.getReceiveID());
				String senderName = laboratoryMapper.getNameById(workFlowTask.getSenderID());
				
				newWork.setReceiveName(receiveName);
				newWork.setSenderName(senderName);
				Integer sort = newWork.getSort();
				newWork.setReceiveTime(DateUtil.getCurrentTime());
				newWork.setSort(sort+1);
				newWork.setStatus(0);
				newWork.setNote("");
				newWork.setSenderTime(DateUtil.getCurrentTime());
				//派工的具体事项 代办事项列表
				laboratoryMapper.insertWorkOrder(newWork);
				
				//发送推送
				DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
				Users users=new Users();
				users.setId(workFlowTask.getReceiveID());
				Users detailUser = userMapper.getDetailUser(users);
				
				
				Map<String, String> parm = new HashMap<>();
				parm.put("title",newWork.getTitle());
				parm.put("messageType", "待办事项");
				parm.put("msg", "审核"+"         "+DateUtil.getCurrentTime());
				parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
				Jdpush.jpushAlias(parm);
				
				Map<String, String> parm1 = new HashMap<>();
				parm1.put("title",newWork.getTitle());
				parm1.put("messageType", "待办事项");
				parm1.put("msg", "审核"+"         "+DateUtil.getCurrentTime());
				parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
				Jdpush.jpushAlias(parm1);
		return JsonUtil.blank(true, 200, "提交成功");
	}

	@Override
	public String samplesMessAdd(Sample sample) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		laboratoryMapper.samplesMessAdd(sample);
		return JsonUtil.blank(true, 200, "添加样品信息成功");
	}

	@Override
	public String samplesMessList(Sample sample) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		List<Sample> list = new ArrayList<Sample>();
		list = laboratoryMapper.samplesMessList(sample);
		JsonUtil jsonUtil = new JsonUtil();
		jsonUtil.setList(list);
		return jsonUtil.getJson();
	}

	@Override
	public String entrustDetail(LabsFlowA labsFlowA,WorkFlowTask workFlowTask) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		//返回详情
		LabsFlowA lA = laboratoryMapper.entrustDetail(labsFlowA);
		//更改打开时间
		workFlowTask.setOpenTime(DateUtil.getCurrentTime());
		laboratoryMapper.setOpenTime(workFlowTask);
		//根据limsid查询 消息详情
		workFlowTask.setID(workFlowTask.getLimsId());
		WorkFlowTask messageDetail = laboratoryMapper.getMessageDetail(workFlowTask);
		
		String groupID = messageDetail.getGroupID();
		//通过groupid查询 收样是否完成
		WorkFlowTask wTask = laboratoryMapper.entrustIsFinish(groupID);
		String to="ab8df631-da1f-4f9c-b8ad-6db384298938";
		if (wTask.getStepID()==to) {
			lA.setLbt1(1);
		}
		if (wTask.getStepID()!=to) {
			lA.setLbt1(0);
		}
		JsonUtil jsonUtil = new JsonUtil();
		jsonUtil.add(lA);
		return jsonUtil.getJson();
	}

	@Override
	public String entrustFinish(LabsFlowA labsFlowA, WorkFlowTask workFlowTask) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		
		
		WorkFlowTask newWork = new WorkFlowTask();
		//获取委托发起人信息 以便推送
		workFlowTask.setID(workFlowTask.getLimsId());
		//当前消息的具体信息
		WorkFlowTask messageDetail = laboratoryMapper.getMessageDetail(workFlowTask);
		//第一条消息的信息
		WorkFlowTask wTask = laboratoryMapper.getFQRMess(messageDetail);
		//如果样品收样审核通过
		
		
		//通过流程id获得json字符串 解析获得具体的流程
		String flowID = wTask.getFlowID();
		String returnJson = laboratoryMapper.getreturnJson(flowID);
		
		//解析json字符串
		Gson gson = new Gson();
		Rootobject gda = gson.fromJson(returnJson, Rootobject.class);
		Step[] steps = gda.getSteps();
		Integer jInteger=0;
		for (int i = 0; i < steps.length; i++) {
			String id2 = steps[i].getId();
			//获取流程的list 如果和当前流程id相同 则 获取下一个流程的id
			if (id2.equals(wTask.getStepID().toLowerCase())) {
					jInteger=i;
				
				break;
			}
		}
		if (labsFlowA.getIsFinish()==1) {
			
			//先修改收样信息
			String instanceID = messageDetail.getInstanceID();
			Integer valueOf = Integer.valueOf(instanceID);
			labsFlowA.setID(valueOf);
			laboratoryMapper.entrustFinish(labsFlowA);
			
		
		//待办变已办，给发起人推送完成通知，LabsFlowA字段Lbt1（流程是否完成）改为1
		workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
		workFlowTask.setOpenTime(DateUtil.getCurrentTime());
		workFlowTask.setStatus(2);
		laboratoryMapper.updateMessageState(workFlowTask);
		//获取收样发起人的信息
		
		//发送推送
		DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
		Users users=new Users();
		users.setId(wTask.getSenderID());
		Users detailUser = userMapper.getDetailUser(users);
		
		
		Map<String, String> parm = new HashMap<>();
		parm.put("title",messageDetail.getTitle());
		parm.put("messageType", "待办事项");
		parm.put("msg", "试验室收样完成"+"         "+DateUtil.getCurrentTime());
		parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
		Jdpush.jpushAlias(parm);
		
		Map<String, String> parm1 = new HashMap<>();
		parm1.put("title",messageDetail.getTitle());
		parm1.put("messageType", "待办事项");
		parm1.put("msg", "试验室收样完成"+"         "+DateUtil.getCurrentTime());
		parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
		Jdpush.jpushAlias(parm1);
		}
		
		//如果不通过
		if (labsFlowA.getIsFinish()==0) {
			
			newWork.setStepID(steps[jInteger].getId());
			newWork.setStepName(steps[jInteger].getName());
			//status 消息状态改为2 已退回
			//改变接收到的消息状态为已读
			workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
			workFlowTask.setOpenTime(DateUtil.getCurrentTime());
			workFlowTask.setStatus(2);
			laboratoryMapper.updateMessageState(workFlowTask);
			
			//重新填写委托收样的信息
			laboratoryMapper.updateEntrustReceived(labsFlowA);
			
			//获取 步骤的名称 id 发送一条消息给发起人
			String receiveName = wTask.getReceiveName();
			String receiveID = wTask.getReceiveID();
			String senderID = wTask.getSenderID();
			String senderName = wTask.getSenderName();
		
			
			newWork.setPrevStepID(messageDetail.getStepID());
			newWork.setPrevID(messageDetail.getID());
			newWork.setID(new RandomGUID().toString());
			newWork.setReceiveID(senderID);
			newWork.setSenderID(receiveID);
			newWork.setReceiveName(senderName);
			newWork.setSenderName(receiveName);
			newWork.setNote("退回任务");
			Integer sort = messageDetail.getSort();
			newWork.setFlowID(messageDetail.getFlowID());
			newWork.setInstanceID(messageDetail.getInstanceID());
			newWork.setReceiveTime(DateUtil.getCurrentTime());
			newWork.setSort(sort+1);
			newWork.setStatus(0);
			newWork.setSenderTime(DateUtil.getCurrentTime());
			newWork.setType(4);
			newWork.setGroupID(messageDetail.getGroupID());
			newWork.setTitle(messageDetail.getTitle());
			//插入 代办事项列表
			laboratoryMapper.insertWorkOrder(newWork);
			
			//发送推送
			DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
			Users users=new Users();
			users.setId(wTask.getSenderID());
			Users detailUser = userMapper.getDetailUser(users);
			
			
			Map<String, String> parm = new HashMap<>();
			parm.put("title",messageDetail.getTitle());
			parm.put("messageType", "待办事项");
			parm.put("msg", "试验室收样退回"+"         "+DateUtil.getCurrentTime());
			parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
			Jdpush.jpushAlias(parm);
			
			Map<String, String> parm1 = new HashMap<>();
			parm1.put("title",messageDetail.getTitle());
			parm1.put("messageType", "待办事项");
			parm1.put("msg", "试验室收样退回"+"         "+DateUtil.getCurrentTime());
			parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
			Jdpush.jpushAlias(parm1);
		}

		return JsonUtil.blank(true, 200, "调用接口成功");
	}

	@Override
	public String samplesProjetList(LabsFlowA labsFlowA) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		List<LabsFlowA> arrayList = new ArrayList<LabsFlowA>();
		arrayList = laboratoryMapper.samplesProjetList(labsFlowA);
		JsonUtil jsonUtil = new JsonUtil();		
		jsonUtil.setList(arrayList);
		return jsonUtil.getJson();
	}

	@Override
	public String samplesProjetSearch(LabsFlowA labsFlowA) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		JsonUtil jsonUtil = new JsonUtil();
		LabsFlowA aFlowA = laboratoryMapper.samplesProjetSearch(labsFlowA);
		jsonUtil.add(aFlowA);
		return jsonUtil.getJson();
	}

	@Override
	public String entrustReceivedCommit(LabsFlowA labsFlowA,WorkFlowTask workFlowTask) {
				DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
				//改变接收到的消息状态为已读
				workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
				workFlowTask.setOpenTime(DateUtil.getCurrentTime());
				workFlowTask.setStatus(2);
				laboratoryMapper.updateMessageState(workFlowTask);
				//重新填写委托收样的信息
				laboratoryMapper.updateEntrustReceived(labsFlowA);
		
				//获取 步骤的名称 id 发送一条消息给接收人
				workFlowTask.setID(workFlowTask.getLimsId());
				//当前消息的具体信息
				WorkFlowTask messageDetail = laboratoryMapper.getMessageDetail(workFlowTask);
				//第一条消息的信息
				WorkFlowTask fTask = laboratoryMapper.getFQRMess(messageDetail);
				WorkFlowTask newWork = new WorkFlowTask();
				//获取步骤id  步骤名称
				newWork.setStepID("ab8df631-da1f-4f9c-b8ad-6db384298938");
				newWork.setStepName("试验室-收样完成");
				
				newWork.setPrevStepID(messageDetail.getStepID());
				newWork.setPrevID(messageDetail.getID());
				newWork.setID(new RandomGUID().toString());
				newWork.setReceiveID(workFlowTask.getReceiveID());
				newWork.setSenderID(fTask.getSenderID());
				newWork.setReceiveName(workFlowTask.getReceiveName());
				newWork.setSenderName(fTask.getSenderName());
				Integer sort = messageDetail.getSort();
				newWork.setFlowID(messageDetail.getFlowID());
				newWork.setInstanceID(messageDetail.getInstanceID());
				newWork.setReceiveTime(DateUtil.getCurrentTime());
				newWork.setSort(sort+1);
				newWork.setStatus(0);
				newWork.setSenderTime(DateUtil.getCurrentTime());
				newWork.setType(0);
				newWork.setNote("");
				newWork.setGroupID(messageDetail.getGroupID());
				newWork.setTitle(messageDetail.getTitle());
				//插入 代办事项列表
				laboratoryMapper.insertWorkOrder(newWork);
				
				//调用推送
				//发送推送
				DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
				Users users=new Users();
				users.setId(workFlowTask.getReceiveID());
				Users detailUser = userMapper.getDetailUser(users);
				
				
				Map<String, String> parm = new HashMap<>();
				parm.put("title",messageDetail.getTitle());
				parm.put("messageType", "待办事项");
				parm.put("msg", "试验室收样完成"+"         "+DateUtil.getCurrentTime());
				parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
				Jdpush.jpushAlias(parm);
				
				Map<String, String> parm1 = new HashMap<>();
				parm1.put("title",messageDetail.getTitle());
				parm1.put("messageType", "待办事项");
				parm1.put("msg", "试验室收样完成"+"         "+DateUtil.getCurrentTime());
				parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
				Jdpush.jpushAlias(parm1);
				
				return JsonUtil.blank(true, 200, "调用接口成功");
	}

	@Override
	public String projetDispatching(LabsFlowA labsFlowA) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		List<LabsFlowA> arrayList = new ArrayList<LabsFlowA>();
		arrayList = laboratoryMapper.projetDispatching(labsFlowA);
		JsonUtil jsonUtil = new JsonUtil();		
		jsonUtil.setList(arrayList);
		return jsonUtil.getJson();
	}

	@Override
	public String projetDispatchingSearch(LabsFlowA labsFlowA) {
		
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		JsonUtil jsonUtil = new JsonUtil();	
		LabsFlowA lA = laboratoryMapper.projetDispatchingSearch(labsFlowA);
		jsonUtil.add(lA);
		return jsonUtil.getJson();
	}

	@Override
	public String detectionTaskInform(LabsFlowA labsFlowA, WorkFlowTask workFlowTask) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		//获取消息的具体信息
		WorkFlowTask newWork = new WorkFlowTask();
		//获取委托发起人信息 以便推送
		workFlowTask.setID(workFlowTask.getLimsId());
		//当前消息的具体信息
		WorkFlowTask messageDetail = laboratoryMapper.getMessageDetail(workFlowTask);
		//第一条消息的信息
		WorkFlowTask wTask = laboratoryMapper.getFQRMess(messageDetail);
		//如果是完成
		if (labsFlowA.getIsFinish()==1) {
		//改变数据状态
		laboratoryMapper.detectionTaskInform(labsFlowA);
			
			//修改消息的状态 
			workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
			workFlowTask.setOpenTime(DateUtil.getCurrentTime());
			workFlowTask.setStatus(2);
			laboratoryMapper.updateMessageState(workFlowTask);
			//给发起人发送推送
			//发送推送
			DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
			Users users=new Users();
			users.setId(wTask.getSenderID());
			Users detailUser = userMapper.getDetailUser(users);
			
			
			Map<String, String> parm = new HashMap<>();
			parm.put("title",messageDetail.getTitle());
			parm.put("messageType", "待办事项");
			parm.put("msg", "检测任务通知书已完成"+"         "+DateUtil.getCurrentTime());
			parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
			Jdpush.jpushAlias(parm);
			
			Map<String, String> parm1 = new HashMap<>();
			parm1.put("title",messageDetail.getTitle());
			parm1.put("messageType", "待办事项");
			parm1.put("msg", "检测任务通知书已完成"+"         "+DateUtil.getCurrentTime());
			parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
			Jdpush.jpushAlias(parm1);
		}

		//如果是不完成
		if (labsFlowA.getIsFinish()==0) {
			DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		//改变数据
		laboratoryMapper.detectionTaskInform(labsFlowA);
		
		//修改消息的状态
		workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
		workFlowTask.setOpenTime(DateUtil.getCurrentTime());
		workFlowTask.setStatus(2);
		laboratoryMapper.updateMessageState(workFlowTask);
		
		//消息退回给发起人 并且insert 一条待办事项
		//获取步骤id  步骤名称
		newWork.setStepID("2d7df89c-42e7-4716-942b-390a9cd35f4a");
		newWork.setStepName("试验室-任务指派");
		
		newWork.setPrevStepID(messageDetail.getStepID());
		newWork.setPrevID(messageDetail.getID());
		newWork.setID(new RandomGUID().toString());
		newWork.setReceiveID(wTask.getSenderID());
		newWork.setSenderID(messageDetail.getReceiveID());
		newWork.setReceiveName(wTask.getSenderName());
		newWork.setSenderName(messageDetail.getReceiveName());
		Integer sort = messageDetail.getSort();
		newWork.setFlowID(messageDetail.getFlowID());
		newWork.setInstanceID(messageDetail.getInstanceID());
		newWork.setReceiveTime(DateUtil.getCurrentTime());
		newWork.setSort(sort+1);
		newWork.setStatus(0);
		newWork.setSenderTime(DateUtil.getCurrentTime());
		newWork.setType(4);
		newWork.setGroupID(messageDetail.getGroupID());
		newWork.setNote("退回任务");
		newWork.setTitle(messageDetail.getTitle());
		//插入 代办事项列表
		laboratoryMapper.insertWorkOrder(newWork);
		
		
		//给发起人发送推送
		DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
		Users users=new Users();
		users.setId(wTask.getSenderID());
		Users detailUser = userMapper.getDetailUser(users);
		
		
		Map<String, String> parm = new HashMap<>();
		parm.put("title",messageDetail.getTitle());
		parm.put("messageType", "待办事项");
		parm.put("msg", "检测任务通知书已退回"+"         "+DateUtil.getCurrentTime());
		parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
		Jdpush.jpushAlias(parm);
		
		Map<String, String> parm1 = new HashMap<>();
		parm1.put("title",messageDetail.getTitle());
		parm1.put("messageType", "待办事项");
		parm1.put("msg", "检测任务通知书已退回"+"         "+DateUtil.getCurrentTime());
		parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
		Jdpush.jpushAlias(parm1);
		}
		return JsonUtil.blank(true, 200, "调用接口成功");
	}

	@Override
	public String detectionTaskCommit(LabsFlowA labsFlowA, WorkFlowTask workFlowTask) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());	
		//获取消息的具体信息
				WorkFlowTask newWork = new WorkFlowTask();
				//获取委托发起人信息 以便推送
				workFlowTask.setID(workFlowTask.getLimsId());
				//当前消息的具体信息
				WorkFlowTask messageDetail = laboratoryMapper.getMessageDetail(workFlowTask);
				//改变收到的消息的消息状态 为已读已完成
				//修改消息的状态 
				workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
				workFlowTask.setOpenTime(DateUtil.getCurrentTime());
				workFlowTask.setStatus(2);
				laboratoryMapper.updateMessageState(workFlowTask);
				//改变数据库 检测通知 的数据
				//改变数据
				laboratoryMapper.detectionTaskInform(labsFlowA);
		//插入一条待办事项
				//获取步骤id  步骤名称
				newWork.setStepID("ba7004db-ac26-4215-bd48-e02a5ad42eb2");
				newWork.setStepName("试验室-接收任务");
				
				newWork.setPrevStepID(messageDetail.getStepID());
				newWork.setPrevID(messageDetail.getID());
				newWork.setID(new RandomGUID().toString());
				newWork.setReceiveID(workFlowTask.getReceiveID());
				newWork.setSenderID(messageDetail.getReceiveID());
				newWork.setReceiveName(workFlowTask.getReceiveName());
				newWork.setSenderName(messageDetail.getReceiveName());
				Integer sort = messageDetail.getSort();
				newWork.setFlowID(messageDetail.getFlowID());
				newWork.setInstanceID(messageDetail.getInstanceID());
				newWork.setReceiveTime(DateUtil.getCurrentTime());
				newWork.setSort(sort+1);
				newWork.setStatus(0);
				newWork.setSenderTime(DateUtil.getCurrentTime());
				newWork.setType(4);
				newWork.setNote("");
				newWork.setGroupID(messageDetail.getGroupID());
				newWork.setTitle(messageDetail.getTitle());
				//插入 代办事项列表
				laboratoryMapper.insertWorkOrder(newWork);
				//发起推送
				DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
				Users users=new Users();
				users.setId(workFlowTask.getReceiveID());
				Users detailUser = userMapper.getDetailUser(users);
				
				
				Map<String, String> parm = new HashMap<>();
				parm.put("title",messageDetail.getTitle());
				parm.put("messageType", "待办事项");
				parm.put("msg", "检测内容通知书-接收任务"+"         "+DateUtil.getCurrentTime());
				parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
				Jdpush.jpushAlias(parm);
				
				Map<String, String> parm1 = new HashMap<>();
				parm1.put("title",messageDetail.getTitle());
				parm1.put("messageType", "待办事项");
				parm1.put("msg", "检测内容通知书-接收任务"+"         "+DateUtil.getCurrentTime());
				parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
				Jdpush.jpushAlias(parm1);	
		return JsonUtil.blank(true, 200, "检测内容通知书-接收任务");
	}

	@Override
	public String detectionTaskDetail(LabsFlowA labsFlowA) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		JsonUtil jsonUtil = new JsonUtil();
		LabsFlowA aFlowA = laboratoryMapper.detectionTaskDetail(labsFlowA);
		if (aFlowA.getTestMan()!=null && !aFlowA.getTestMan().equals("")) {
			String testMan = aFlowA.getTestMan();
			String fsr = testMan.substring(2);
			String nString = laboratoryMapper.getNameById(fsr);
			aFlowA.setTestName(nString);
		}
		jsonUtil.add(aFlowA);
		return jsonUtil.getJson();
	}

	@Override
	public String LabReportDetail(LabsFlowA labsFlowA) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		JsonUtil jsonUtil = new JsonUtil();	
		LabsFlowA aFlowA = laboratoryMapper.LabReportDetail(labsFlowA);
		if (!aFlowA.getGetMan().equals("")&&aFlowA.getGetMan()!=null) {
			String getMan = aFlowA.getGetMan();
			String fsr = getMan.substring(2);
			String nString = laboratoryMapper.getNameById(fsr);
			aFlowA.setGetName(nString);
		}
		jsonUtil.add(aFlowA);
		return jsonUtil.getJson();
	}

	@Override
	public String LabReportSubmitOrModify(LabsFlowA labsFlowA, WorkFlowTask workFlowTask) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		//获取消息详情信息
		WorkFlowTask newWork = new WorkFlowTask();
		//获取委托发起人信息 以便推送
		workFlowTask.setID(workFlowTask.getLimsId());
		//当前消息的具体信息
		WorkFlowTask messageDetail = laboratoryMapper.getMessageDetail(workFlowTask);
		//第一条消息的信息
		WorkFlowTask wTask = laboratoryMapper.getFQRMess(messageDetail);
		//改变收到的消息的消息状态 为已读已完成
		//修改消息的状态 
		workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
		workFlowTask.setOpenTime(DateUtil.getCurrentTime());
		workFlowTask.setStatus(2);
		laboratoryMapper.updateMessageState(workFlowTask);
		
		//改变试验修改的数据
		laboratoryMapper.LabReportSubmit(labsFlowA);
		//如果通过审核 
		if (labsFlowA.getIsFinish()==1) {
		//改变消息为已读
			workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
			workFlowTask.setOpenTime(DateUtil.getCurrentTime());
			workFlowTask.setStatus(2);
			laboratoryMapper.updateMessageState(workFlowTask);
		
			//生成一条新消息 向下一个流程发送推送
			//获取步骤id  步骤名称
			newWork.setStepID("cc1b8324-276b-47e2-be77-7b6dc7ed9545");
			newWork.setStepName("审批");
			
			newWork.setPrevStepID(messageDetail.getStepID());
			newWork.setPrevID(messageDetail.getID());
			newWork.setID(new RandomGUID().toString());
			newWork.setReceiveID(workFlowTask.getReceiveID());
			newWork.setSenderID(messageDetail.getReceiveID());
			newWork.setReceiveName(workFlowTask.getReceiveName());
			newWork.setSenderName(messageDetail.getReceiveName());
			Integer sort = messageDetail.getSort();
			newWork.setFlowID(messageDetail.getFlowID());
			newWork.setInstanceID(messageDetail.getInstanceID());
			newWork.setReceiveTime(DateUtil.getCurrentTime());
			newWork.setSort(sort+1);
			newWork.setStatus(0);
			newWork.setSenderTime(DateUtil.getCurrentTime());
			newWork.setType(0);
			newWork.setNote("");
			newWork.setGroupID(messageDetail.getGroupID());
			newWork.setTitle(messageDetail.getTitle());
			//插入 代办事项列表
			laboratoryMapper.insertWorkOrder(newWork);
			//发起推送
			DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
			Users users=new Users();
			users.setId(workFlowTask.getReceiveID());
			Users detailUser = userMapper.getDetailUser(users);
			
			
			Map<String, String> parm = new HashMap<>();
			parm.put("title",messageDetail.getTitle());
			parm.put("messageType", "待办事项");
			parm.put("msg", "提交审批"+"         "+DateUtil.getCurrentTime());
			parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
			Jdpush.jpushAlias(parm);
			
			Map<String, String> parm1 = new HashMap<>();
			parm1.put("title",messageDetail.getTitle());
			parm1.put("messageType", "待办事项");
			parm1.put("msg", "提交审批"+"         "+DateUtil.getCurrentTime());
			parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
			Jdpush.jpushAlias(parm1);	
		
		
		}
		//如果没有通过审核
		if (labsFlowA.getIsFinish()==0) {
		//改变消息为已读 状态为退回
			workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
			workFlowTask.setOpenTime(DateUtil.getCurrentTime());
			workFlowTask.setStatus(2);
			laboratoryMapper.updateMessageState(workFlowTask);
			//生成一条新的消息 退回给发送人
			//获取步骤id  步骤名称
			newWork.setStepID("b4d05f53-aeba-409f-8bfd-412aa577fd0c");
			newWork.setStepName("试验修改");
			
			newWork.setPrevStepID(messageDetail.getStepID());
			newWork.setPrevID(messageDetail.getID());
			newWork.setID(new RandomGUID().toString());
			//接收人id
			newWork.setReceiveID(wTask.getSenderID());
			newWork.setSenderID(messageDetail.getReceiveID());
			newWork.setReceiveName(wTask.getSenderName());
			newWork.setSenderName(messageDetail.getReceiveName());
			Integer sort = messageDetail.getSort();
			newWork.setFlowID(messageDetail.getFlowID());
			newWork.setInstanceID(messageDetail.getInstanceID());
			newWork.setReceiveTime(DateUtil.getCurrentTime());
			newWork.setSort(sort+1);
			newWork.setStatus(0);
			newWork.setSenderTime(DateUtil.getCurrentTime());
			newWork.setType(0);
			newWork.setNote("消息退回");
			newWork.setGroupID(messageDetail.getGroupID());
			newWork.setTitle(messageDetail.getTitle());
			//插入 代办事项列表
			laboratoryMapper.insertWorkOrder(newWork);
			//发起推送
			DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
			Users users=new Users();
			users.setId(newWork.getReceiveID());
			Users detailUser = userMapper.getDetailUser(users);
			
			
			Map<String, String> parm = new HashMap<>();
			parm.put("title",messageDetail.getTitle());
			parm.put("messageType", "待办事项");
			parm.put("msg", "退回试验修改"+"         "+DateUtil.getCurrentTime());
			parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
			Jdpush.jpushAlias(parm);
			
			Map<String, String> parm1 = new HashMap<>();
			parm1.put("title",messageDetail.getTitle());
			parm1.put("messageType", "待办事项");
			parm1.put("msg", "退回试验修改"+"         "+DateUtil.getCurrentTime());
			parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
			Jdpush.jpushAlias(parm1);			
		}
		return JsonUtil.blank(true, 200, "调用接口成功");
	}

	@Override
	public String approveSubmitOrModify(LabsFlowA labsFlowA, WorkFlowTask workFlowTask) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		//获取消息详情信息
		WorkFlowTask newWork = new WorkFlowTask();
		//获取委托发起人信息 以便推送
		workFlowTask.setID(workFlowTask.getLimsId());
		//当前消息的具体信息
		WorkFlowTask messageDetail = laboratoryMapper.getMessageDetail(workFlowTask);
		//第一条消息的信息
		WorkFlowTask wTask = laboratoryMapper.getFQRMess(messageDetail);
		//改变收到的消息的消息状态 为已读已完成
		//修改消息的状态 
		workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
		workFlowTask.setOpenTime(DateUtil.getCurrentTime());
		workFlowTask.setStatus(2);
		laboratoryMapper.updateMessageState(workFlowTask);
		
		//改变试验修改的数据
		laboratoryMapper.approvalSubmit(labsFlowA);
		//如果通过审核 
		if (labsFlowA.getIsFinish()==1) {
		//改变消息为已读
			workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
			workFlowTask.setOpenTime(DateUtil.getCurrentTime());
			workFlowTask.setStatus(2);
			laboratoryMapper.updateMessageState(workFlowTask);
		
			//生成一条新消息 向下一个流程发送推送
			//获取步骤id  步骤名称
			newWork.setStepID("c25ebb64-58b0-487a-b028-2697b429cc09");
			newWork.setStepName("出报告");
			
			newWork.setPrevStepID(messageDetail.getStepID());
			newWork.setPrevID(messageDetail.getID());
			newWork.setID(new RandomGUID().toString());
			newWork.setReceiveID(workFlowTask.getReceiveID());
			newWork.setSenderID(messageDetail.getReceiveID());
			newWork.setReceiveName(workFlowTask.getReceiveName());
			newWork.setSenderName(messageDetail.getReceiveName());
			Integer sort = messageDetail.getSort();
			newWork.setFlowID(messageDetail.getFlowID());
			newWork.setInstanceID(messageDetail.getInstanceID());
			newWork.setReceiveTime(DateUtil.getCurrentTime());
			newWork.setSort(sort+1);
			newWork.setStatus(0);
			newWork.setSenderTime(DateUtil.getCurrentTime());
			newWork.setType(0);
			newWork.setNote("");
			newWork.setGroupID(messageDetail.getGroupID());
			newWork.setTitle(messageDetail.getTitle());
			//插入 代办事项列表
			laboratoryMapper.insertWorkOrder(newWork);
			//发起推送
			DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
			Users users=new Users();
			users.setId(newWork.getReceiveID());
			Users detailUser = userMapper.getDetailUser(users);
			
			
			Map<String, String> parm = new HashMap<>();
			parm.put("title",messageDetail.getTitle());
			parm.put("messageType", "待办事项");
			parm.put("msg", "出报告"+"         "+DateUtil.getCurrentTime());
			parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
			Jdpush.jpushAlias(parm);
			
			Map<String, String> parm1 = new HashMap<>();
			parm1.put("title",messageDetail.getTitle());
			parm1.put("messageType", "待办事项");
			parm1.put("msg", "出报告"+"         "+DateUtil.getCurrentTime());
			parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
			Jdpush.jpushAlias(parm1);	
		
		
		}
		//如果没有通过审核
		if (labsFlowA.getIsFinish()==0) {
		//改变消息为已读 状态为退回
			workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
			workFlowTask.setOpenTime(DateUtil.getCurrentTime());
			workFlowTask.setStatus(2);
			laboratoryMapper.updateMessageState(workFlowTask);
			//生成一条新的消息 退回给发送人
			//获取步骤id  步骤名称
			newWork.setStepID("d963b5e7-dca5-43aa-ab70-7020ff2c2144");
			newWork.setStepName("审核");
			
			newWork.setPrevStepID(messageDetail.getStepID());
			newWork.setPrevID(messageDetail.getID());
			newWork.setID(new RandomGUID().toString());
			//接收人id
			newWork.setReceiveID(messageDetail.getSenderID());
			newWork.setSenderID(messageDetail.getReceiveID());
			newWork.setReceiveName(messageDetail.getSenderName());
			newWork.setSenderName(messageDetail.getReceiveName());
			Integer sort = messageDetail.getSort();
			newWork.setFlowID(messageDetail.getFlowID());
			newWork.setInstanceID(messageDetail.getInstanceID());
			newWork.setReceiveTime(DateUtil.getCurrentTime());
			newWork.setSort(sort+1);
			newWork.setStatus(0);
			newWork.setSenderTime(DateUtil.getCurrentTime());
			newWork.setType(0);
			newWork.setNote("消息退回");
			newWork.setGroupID(messageDetail.getGroupID());
			newWork.setTitle(messageDetail.getTitle());
			//插入 代办事项列表
			laboratoryMapper.insertWorkOrder(newWork);
			//发起推送
			DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
			Users users=new Users();
			users.setId(newWork.getReceiveID());
			Users detailUser = userMapper.getDetailUser(users);
			
			
			Map<String, String> parm = new HashMap<>();
			parm.put("title",messageDetail.getTitle());
			parm.put("messageType", "待办事项");
			parm.put("msg", "退回审批"+"         "+DateUtil.getCurrentTime());
			parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
			Jdpush.jpushAlias(parm);
			
			Map<String, String> parm1 = new HashMap<>();
			parm1.put("title",messageDetail.getTitle());
			parm1.put("messageType", "待办事项");
			parm1.put("msg", "退回审批"+"         "+DateUtil.getCurrentTime());
			parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
			Jdpush.jpushAlias(parm1);			
		}
		return JsonUtil.blank(true, 200, "调用接口成功");
	}

	@Override
	public String reportSubmit(LabsFlowA labsFlowA, WorkFlowTask workFlowTask) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
				//获取消息详情信息
				WorkFlowTask newWork = new WorkFlowTask();
				//获取委托发起人信息 以便推送
				workFlowTask.setID(workFlowTask.getLimsId());
				//当前消息的具体信息
				WorkFlowTask messageDetail = laboratoryMapper.getMessageDetail(workFlowTask);
				//第一条消息的信息
				WorkFlowTask wTask = laboratoryMapper.getFQRMess(messageDetail);
				//改变收到的消息的消息状态 为已读已完成
				//修改消息的状态 
				workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
				workFlowTask.setOpenTime(DateUtil.getCurrentTime());
				workFlowTask.setStatus(2);
				laboratoryMapper.updateMessageState(workFlowTask);
				
				//改变试验修改的数据
				laboratoryMapper.LabReportSubmit1(labsFlowA);
				//如果通过审核 
				if (labsFlowA.getIsFinish()==1) {
				//改变消息为已读
					workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
					workFlowTask.setOpenTime(DateUtil.getCurrentTime());
					workFlowTask.setStatus(2);
					laboratoryMapper.updateMessageState(workFlowTask);
				
					
					//发起推送
					DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
					Users users=new Users();
					users.setId(wTask.getSenderID());
					Users detailUser = userMapper.getDetailUser(users);
					
					
					Map<String, String> parm = new HashMap<>();
					parm.put("title",messageDetail.getTitle());
					parm.put("messageType", "待办事项");
					parm.put("msg", "出报告完成"+"         "+DateUtil.getCurrentTime());
					parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
					Jdpush.jpushAlias(parm);
					
					Map<String, String> parm1 = new HashMap<>();
					parm1.put("title",messageDetail.getTitle());
					parm1.put("messageType", "待办事项");
					parm1.put("msg", "出报告完成"+"         "+DateUtil.getCurrentTime());
					parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
					Jdpush.jpushAlias(parm1);	
				
				
				}
				//如果没有通过审核
				if (labsFlowA.getIsFinish()==0) {
				//改变消息为已读 状态为退回
					workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
					workFlowTask.setOpenTime(DateUtil.getCurrentTime());
					workFlowTask.setStatus(3);
					laboratoryMapper.updateMessageState(workFlowTask);
					//生成一条新的消息 退回给发送人
					//获取步骤id  步骤名称
					newWork.setStepID("cc1b8324-276b-47e2-be77-7b6dc7ed9545");
					newWork.setStepName("审批");
					
					newWork.setPrevStepID(messageDetail.getStepID());
					newWork.setPrevID(messageDetail.getID());
					newWork.setID(new RandomGUID().toString());
					//接收人id
					newWork.setReceiveID(messageDetail.getSenderID());
					newWork.setSenderID(messageDetail.getReceiveID());
					newWork.setReceiveName(messageDetail.getSenderName());
					newWork.setSenderName(messageDetail.getReceiveName());
					Integer sort = messageDetail.getSort();
					newWork.setFlowID(messageDetail.getFlowID());
					newWork.setInstanceID(messageDetail.getInstanceID());
					newWork.setReceiveTime(DateUtil.getCurrentTime());
					newWork.setSort(sort+1);
					newWork.setStatus(0);
					newWork.setSenderTime(DateUtil.getCurrentTime());
					newWork.setType(4);
					newWork.setNote("消息退回");
					newWork.setGroupID(messageDetail.getGroupID());
					newWork.setTitle(messageDetail.getTitle());
					//插入 代办事项列表
					laboratoryMapper.insertWorkOrder(newWork);
					//发起推送
					DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
					Users users=new Users();
					users.setId(newWork.getReceiveID());
					Users detailUser = userMapper.getDetailUser(users);
					
					
					Map<String, String> parm = new HashMap<>();
					parm.put("title",messageDetail.getTitle());
					parm.put("messageType", "待办事项");
					parm.put("msg", "退回审批"+"         "+DateUtil.getCurrentTime());
					parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
					Jdpush.jpushAlias(parm);
					
					Map<String, String> parm1 = new HashMap<>();
					parm1.put("title",messageDetail.getTitle());
					parm1.put("messageType", "待办事项");
					parm1.put("msg", "退回审批"+"         "+DateUtil.getCurrentTime());
					parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
					Jdpush.jpushAlias(parm1);			
				}
				return JsonUtil.blank(true, 200, "调用接口成功");
	}

	@Override
	public String testTomModify(LabsFlowA labsFlowA, WorkFlowTask workFlowTask) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		//改变试验修改的数据
		laboratoryMapper.testTomModify(labsFlowA);
		//获取消息详情信息
			WorkFlowTask newWork = new WorkFlowTask();
			//获取委托发起人信息 以便推送
			workFlowTask.setID(workFlowTask.getLimsId());
			//当前消息的具体信息
			WorkFlowTask messageDetail = laboratoryMapper.getMessageDetail(workFlowTask);
			//第一条消息的信息
			WorkFlowTask wTask = laboratoryMapper.getFQRMess(messageDetail);
			//改变收到的消息的消息状态 为已读已完成
		//改变消息为已读
		workFlowTask.setCompletedTime1(DateUtil.getCurrentTime());
		workFlowTask.setOpenTime(DateUtil.getCurrentTime());
		workFlowTask.setStatus(2);
		laboratoryMapper.updateMessageState(workFlowTask);
	
		//生成一条新消息 向下一个流程发送推送
		//获取步骤id  步骤名称
		newWork.setStepID("d963b5e7-dca5-43aa-ab70-7020ff2c2144");
		newWork.setStepName("审核");
		
		newWork.setPrevStepID(messageDetail.getStepID());
		newWork.setPrevID(messageDetail.getID());
		newWork.setID(new RandomGUID().toString());
		newWork.setReceiveID(workFlowTask.getReceiveID());
		newWork.setSenderID(messageDetail.getReceiveID());
		newWork.setReceiveName(workFlowTask.getReceiveName());
		newWork.setSenderName(messageDetail.getReceiveName());
		Integer sort = messageDetail.getSort();
		newWork.setFlowID(messageDetail.getFlowID());
		newWork.setInstanceID(messageDetail.getInstanceID());
		newWork.setReceiveTime(DateUtil.getCurrentTime());
		newWork.setSort(sort+1);
		newWork.setStatus(0);
		newWork.setSenderTime(DateUtil.getCurrentTime());
		newWork.setType(0);
		newWork.setNote("");
		newWork.setGroupID(messageDetail.getGroupID());
		newWork.setTitle(messageDetail.getTitle());
		//插入 代办事项列表
		laboratoryMapper.insertWorkOrder(newWork);
		//发起推送
		DataSourceHolder.setDataSources(DataSourceEnum.DS1.getKey());
		Users users=new Users();
		users.setId(newWork.getReceiveID());
		Users detailUser = userMapper.getDetailUser(users);
		
		
		Map<String, String> parm = new HashMap<>();
		parm.put("title",messageDetail.getTitle());
		parm.put("messageType", "待办事项");
		parm.put("msg", "提交审核"+"         "+DateUtil.getCurrentTime());
		parm.put("alias",detailUser.getAccount_ID().toUpperCase().replaceAll("-", ""));
		Jdpush.jpushAlias(parm);
		
		Map<String, String> parm1 = new HashMap<>();
		parm1.put("title",messageDetail.getTitle());
		parm1.put("messageType", "待办事项");
		parm1.put("msg", "提交审核"+"         "+DateUtil.getCurrentTime());
		parm1.put("alias",detailUser.getId().toUpperCase().replaceAll("-", "")); 
		Jdpush.jpushAlias(parm1);
		return JsonUtil.blank(true, 200, "调用接口成功");	
	}

	@Override
	public String testTomModifyList(LabsFlowA labsFlowA) {
		DataSourceHolder.setDataSources(DataSourceEnum.DS2.getKey());
		List<LabsFlowA> arrayList = new ArrayList<LabsFlowA>();
		arrayList = laboratoryMapper.testTomModifyList(labsFlowA);
		JsonUtil jsonUtil = new JsonUtil();		
		jsonUtil.setList(arrayList);
		return jsonUtil.getJson();
	}




	
}
